<template>
	<view class="notice-page">
		<!-- 消息列表 -->
		<view class="message-list">
			<view 
				class="message-item" 
				v-for="(item, index) in messageList" 
				:key="index"
			>
				<view class="message-content">
					<view class="message-header">
						<view class="message-icon">
							<image src="/static/svg/coupon-expired.svg" class="icon" />
						</view>
						<view class="message-info">
							<view class="message-title">{{ item.title }}</view>
							<view class="message-time">{{ item.time }}</view>
						</view>
					</view>
					<view class="message-desc">{{ item.description }}</view>
					<view class="message-action">
						<text class="action-btn" @tap="viewDetails(item)">查看详情 ></text>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 加载更多 -->
		<view class="loading-more" v-if="hasMore">
			<view class="loading-icon">
				<view class="dot"></view>
				<view class="dot"></view>
				<view class="dot"></view>
			</view>
			<text class="loading-text">数据加载中</text>
		</view>
	</view>
</template>

<script setup>
import { ref, onMounted } from 'vue'

// 响应式数据
const messageList = ref([
	{
		id: 1,
		title: '优惠券过期提醒',
		description: '您有1张价值29元的有会员今日到期，快去用掉吧！',
		time: '2017-03-05'
	},
	{
		id: 2,
		title: '优惠券过期提醒',
		description: '您有1张价值29元的有会员今日到期，快去用掉吧！',
		time: '2017-03-05'
	},
	{
		id: 3,
		title: '优惠券过期提醒',
		description: '您有1张价值29元的有会员今日到期，快去用掉吧！',
		time: '2017-03-05'
	},
	{
		id: 4,
		title: '优惠券过期提醒',
		description: '您有1张价值29元的有会员今日到期，快去用掉吧！',
		time: '2017-03-05'
	},
	{
		id: 5,
		title: '优惠券过期提醒',
		description: '您有1张价值29元的有会员今日到期，快去用掉吧！',
		time: '2017-03-05'
	}
])

const hasMore = ref(true)

// 方法
const viewDetails = (item) => {
	console.log('查看详情:', item)
	// 这里可以跳转到详情页面或显示详情弹窗
	uni.showToast({
		title: '查看详情',
		icon: 'none'
	})
}

// 生命周期
onMounted(() => {
	// 页面加载完成后的逻辑
	console.log('优惠券过期提醒页面加载完成')
})
</script>

<style scoped>
.notice-page {
	min-height: 100vh;
	background-color: #f8f8f8;
	padding: 0;
}

.message-list {
	padding: 16rpx 20rpx;
}

.message-item {
	background-color: #ffffff;
	border-radius: 12rpx;
	margin-bottom: 16rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
	overflow: hidden;
	border: 1rpx solid #f0f0f0;
}

.message-content {
	padding: 28rpx 32rpx;
}

.message-header {
	display: flex;
	align-items: flex-start;
	margin-bottom: 20rpx;
}

.message-icon {
	width: 44rpx;
	height: 44rpx;
	margin-right: 20rpx;
	flex-shrink: 0;
}

.icon {
	width: 100%;
	height: 100%;
}

.message-info {
	flex: 1;
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
}

.message-title {
	font-size: 30rpx;
	font-weight: 600;
	color: #333333;
	line-height: 1.4;
}

.message-time {
	font-size: 22rpx;
	color: #cccccc;
	line-height: 1.4;
	margin-left: 20rpx;
	flex-shrink: 0;
}

.message-desc {
	font-size: 26rpx;
	color: #666666;
	line-height: 1.6;
	margin-bottom: 20rpx;
	padding-left: 64rpx;
}

.message-action {
	display: flex;
	justify-content: flex-end;
	padding-left: 64rpx;
}

.action-btn {
	font-size: 26rpx;
	color: #FF6E31;
	font-weight: 500;
	cursor: pointer;
	transition: opacity 0.2s;
	padding: 8rpx 0;
}

.action-btn:active {
	opacity: 0.7;
}

/* 加载更多样式 */
.loading-more {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40rpx;
	color: #999999;
}

.loading-icon {
	display: flex;
	align-items: center;
	margin-bottom: 16rpx;
}

.dot {
	width: 6rpx;
	height: 6rpx;
	border-radius: 50%;
	background-color: #cccccc;
	margin: 0 3rpx;
	animation: loading 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
	animation-delay: -0.32s;
}

.dot:nth-child(2) {
	animation-delay: -0.16s;
}

.loading-text {
	font-size: 22rpx;
	color: #999999;
}

@keyframes loading {
	0%, 80%, 100% {
		transform: scale(0);
		opacity: 0.5;
	}
	40% {
		transform: scale(1);
		opacity: 1;
	}
}

/* 响应式设计 */
@media (max-width: 750rpx) {
	.message-content {
		padding: 24rpx 28rpx;
	}
	
	.message-title {
		font-size: 28rpx;
	}
	
	.message-desc {
		font-size: 24rpx;
		padding-left: 60rpx;
	}
	
	.message-action {
		padding-left: 60rpx;
	}
	
	.action-btn {
		font-size: 24rpx;
	}
}
</style>
